package com.qwert.shortlink.admin.remote.dto;

import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.TypeReference;
import com.qwert.shortlink.admin.common.convention.result.Result;

import java.util.HashMap;

/**
 * @author qwert
 * @version 1.0.0
 * @create 2024/7/6 18:30
 **/
public interface RedirectLinkRemoteService {
    /**
     * 远程调用获取目的链接标题
     */
    default Result<String> getTitleByUrl(String aimUrl) {
        HashMap<String, Object> requestMap = new HashMap<>();
        requestMap.put("aimUrl", aimUrl);
        String resultStr = HttpUtil.get("http://localhost:8001/api/shortlink/title", requestMap);
        return JSON.parseObject(resultStr, new TypeReference<>() {
        });
    }
}
